package com.kxf.androidtestdemo.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.usage.NetworkStatsManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
import android.util.Log;

import com.kxf.androidtestdemo.R;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ServiceTestActivity extends AppCompatActivity {

    @TargetApi(Build.VERSION_CODES.P)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_service_test);

        NetworkStatsManager networkStatsManager = (NetworkStatsManager) getSystemService(Context.NETWORK_STATS_SERVICE);
        Log.i("ServiceTestActivity", "networkStatsManager  " + networkStatsManager);
        PackageManager packageManager = getPackageManager();
        Log.i("ServiceTestActivity", "packageManager  " + packageManager.isInstantApp());

//        PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
//        Log.i("ServiceTestActivity", "powerManager  " + powerManager.getLocationPowerSaveMode());

        ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.AppTask> apps = activityManager.getAppTasks();
        for (ActivityManager.AppTask app : apps){
            Log.i("ServiceTestActivity", "activityManager  " + app.getTaskInfo().baseActivity);
        }
    }
}
